<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>分公司交易统计</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href="<s:url value="/css/common.css"/>"/>
    <!-- 当前页面样式 END -->
    <script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
    <script type="text/javascript">
/* $(document).ready(function() { */
function exportSubmit(){
	var minDate = $.trim($("#minDate").val());
	var maxDate = $.trim($("#maxDate").val()); 
	
	
	
	if(!minDate || !maxDate){
		alert("请选择时间范围");
		return false;
	}
	
	var date1=str2date(minDate);
	var date4=str2date(maxDate);
	if(date1.getMonth()!=date4.getMonth()){
	    alert("选择的时间范围不在同一个月内！");
		return false;
	}
	
	$("#queryUserForm").attr("action","<%=basePath%>/compTrans/exportcompTransList.ct");
	$("#queryUserForm").submit();
			
}	
	
/* }); */
		
function checkSubmit(){
	
	var minDate = $.trim($("#minDate").val());
	var maxDate = $.trim($("#maxDate").val()); 
	
	if(!minDate || !maxDate){
		alert("请选择时间范围");
		return false;
	} 
	
	var date1=str2date(minDate);
	var date4=str2date(maxDate);
	if(date1.getMonth()!=date4.getMonth()){
	    alert("选择的时间范围不在同一个月内！");
		return false;
	}
	$("#queryUserForm").attr("action","<%=basePath%>/compTrans/queryCompTransList.ct");
	$("#queryUserForm").submit();
	$("#queryBtnId").attr("disabled","true");
}

function   str2date(str){   
	var   d=null;   
	var   reg=/^(\d{4})(\d{2})(\d{2})$/  ;
	if(arr=str.match(reg)) d=new Date(Number(arr[1]),Number(arr[2])-1,Number(arr[3])) ; 
	return   d;   
}

</script>
</head>
<body>
<s:form id="queryUserForm" action="" method="post" theme="simple">
<table class="tb">
    <tbody>
        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h2">POS收单运营管理平台</div></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h3">分公司交易统计</div></td>
        </tr>

        <tr class="tb-line">
        	<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">计费日期：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-mini"><s:textfield id="minDate"  name="searchCondition.minDate" 
                onfocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
                /></label>-<label class="tb-input-mini"><s:textfield id="maxDate"  name="searchCondition.maxDate" 
                onfocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
                /></label> <code class="asterisk">*</code>
            </td>
            
            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">分公司：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal"><s:textfield id="orgName" name="searchCondition.orgName" cssClass="queryWidth" /></label>
            </td>
            
         </tr>
         <tr class="tb-line">
            
            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">区域名称：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal"><s:textfield id="companyName" name="searchCondition.companyName" cssClass="queryWidth" /></label>
            </td>
         </tr>

        <tr class="tb-line">
            <td class="tb-td line-submit" align="right" colspan="4">
                <label class="tb-input-submit">
                    <input id="queryBtnId" type="button" value="查   询" onclick="return checkSubmit();" />
                </label>
                <label class="tb-input-submit">
                    <s:if  test="#request.cclist != null && #request.cclist.size>0">
					   		<input id="szPower" type="button"
							value="导 出" onclick="return exportSubmit();"/>
					   
					</s:if>
					<s:else>
					 	<input id="szPower" disabled="disabled" value="导  出" type="button" /> 
					</s:else>
                </label>
            </td>
        </tr>
         <s:if  test="#request.cclist != null && #request.cclist.size>0">
					<tr class="tb-line">
				<td class="tb-td paging"  align="left" colspan="4"> 
					 	<page:pageCount max_pages="11" totalPage="${requestScope.totalPage}"
						currentPage="${requestScope.currentPage}"
						action="${rootPath}/compTrans/queryCompTransList.ct?currentPage=" />

				</td>
			</tr>
	</s:if>
    </tbody>
    
</table>

<div class="big-tb">
    <table class="tb" style="width: 100%;">
        <thead>
            <tr class="tb-line">
                <th class="tb-th" colspan="15">分公司交易统计</th>
            </tr>
            <tr class="tb-line bg-gray">
                		<th class="tb-th">计费日期</th>
						<th class="tb-th">分公司</th>
						<th class="tb-th">总金额(元)</th>
						<th class="tb-th">总笔数</th>
						<th class="tb-th">所属大区</th>
						<th class="tb-th">活跃商户数量</th>
						<th class="tb-th">手续费(元)</th>
						<th class="tb-th">收入(元)</th>
            </tr>
        </thead>
        <tbody>
			<s:iterator value="#request.cclist" status="stat" id="tft">
							<tr  class="tb-line"  >
					        <td class="tb-td">
							<s:property value="#tft.transDt"/>
							</td>
							<td class="tb-td">
							<s:property value="#tft.orgName"/>
							</td>
							<td class="tb-td">
							<s:property value="#tft.sumAmt"/>
							</td>
							<td class="tb-td">
							 <s:property value="#tft.sumCount"/>
							</td>
							<td class="tb-td">
					         <s:property value="#tft.companyName"/>
							</td>
							<td class="tb-td">
							<s:property value="#tft.activeMchtCount"/>
							</td>
							<td class="tb-td">
							<s:property value="#tft.mchtFee"/>
							</td>
							<td class="tb-td">
							<s:property value="#tft.inCome"/>
							</td>
						
						    </tr>
						</s:iterator>
        </tbody>
    </table>
</div>
</s:form>

<s:if test="#request.msg !=null">
		<script language="javascript">
			alert("${request.msg}");
		</script>
	</s:if>
</body>
</html>